/* 
 * Selling Partner API for Listings Items
 *
 * The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API.  For more information, see the [Listings Items API Use Case Guide](doc:listings-items-api-v2021-08-01-use-case-guide).
 *
 * OpenAPI spec version: 2021-08-01
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;

namespace FikaAmazonAPI.AmazonSpApiSDK.Models.ListingsItems
{
    /// <summary>
    /// Individual JSON Patch operation for an HTTP PATCH request.
    /// </summary>
    [DataContract]
    public partial class PatchOperation :  IEquatable<PatchOperation>, IValidatableObject
    {
        /// <summary>
        /// Type of JSON Patch operation. Supported JSON Patch operations include add, replace, and delete. See &lt;https://tools.ietf.org/html/rfc6902&gt;.
        /// </summary>
        /// <value>Type of JSON Patch operation. Supported JSON Patch operations include add, replace, and delete. See &lt;https://tools.ietf.org/html/rfc6902&gt;.</value>
        [JsonConverter(typeof(StringEnumConverter))]
        public enum OpEnum
        {
            
            /// <summary>
            /// Enum Add for value: add
            /// </summary>
            [EnumMember(Value = "add")]
            Add = 1,
            
            /// <summary>
            /// Enum Replace for value: replace
            /// </summary>
            [EnumMember(Value = "replace")]
            Replace = 2,
            
            /// <summary>
            /// Enum Delete for value: delete
            /// </summary>
            [EnumMember(Value = "delete")]
            Delete = 3
        }

        /// <summary>
        /// Type of JSON Patch operation. Supported JSON Patch operations include add, replace, and delete. See &lt;https://tools.ietf.org/html/rfc6902&gt;.
        /// </summary>
        /// <value>Type of JSON Patch operation. Supported JSON Patch operations include add, replace, and delete. See &lt;https://tools.ietf.org/html/rfc6902&gt;.</value>
        [DataMember(Name="op", EmitDefaultValue=false)]
        public OpEnum Op { get; set; }
        /// <summary>
        /// Initializes a new instance of the <see cref="PatchOperation" /> class.
        /// </summary>
        [JsonConstructorAttribute]
        protected PatchOperation() { }
        /// <summary>
        /// Initializes a new instance of the <see cref="PatchOperation" /> class.
        /// </summary>
        /// <param name="op">Type of JSON Patch operation. Supported JSON Patch operations include add, replace, and delete. See &lt;https://tools.ietf.org/html/rfc6902&gt;. (required).</param>
        /// <param name="path">JSON Pointer path of the element to patch. See &lt;https://tools.ietf.org/html/rfc6902&gt;. (required).</param>
        /// <param name="value">JSON value to add, replace, or delete..</param>
        public PatchOperation(OpEnum op = default(OpEnum), string path = default(string), List<Object> value = default(List<Object>))
        {
            // to ensure "op" is required (not null)
            if (op == null)
            {
                throw new InvalidDataException("op is a required property for PatchOperation and cannot be null");
            }
            else
            {
                this.Op = op;
            }
            // to ensure "path" is required (not null)
            if (path == null)
            {
                throw new InvalidDataException("path is a required property for PatchOperation and cannot be null");
            }
            else
            {
                this.Path = path;
            }
            this.Value = value;
        }
        

        /// <summary>
        /// JSON Pointer path of the element to patch. See &lt;https://tools.ietf.org/html/rfc6902&gt;.
        /// </summary>
        /// <value>JSON Pointer path of the element to patch. See &lt;https://tools.ietf.org/html/rfc6902&gt;.</value>
        [DataMember(Name="path", EmitDefaultValue=false)]
        public string Path { get; set; }

        /// <summary>
        /// JSON value to add, replace, or delete.
        /// </summary>
        /// <value>JSON value to add, replace, or delete.</value>
        [DataMember(Name="value", EmitDefaultValue=false)]
        public List<Object> Value { get; set; }

        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("class PatchOperation {\n");
            sb.Append("  Op: ").Append(Op).Append("\n");
            sb.Append("  Path: ").Append(Path).Append("\n");
            sb.Append("  Value: ").Append(Value).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }
  
        /// <summary>
        /// Returns the JSON string presentation of the object
        /// </summary>
        /// <returns>JSON string presentation of the object</returns>
        public virtual string ToJson()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }

        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="input">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object input)
        {
            return this.Equals(input as PatchOperation);
        }

        /// <summary>
        /// Returns true if PatchOperation instances are equal
        /// </summary>
        /// <param name="input">Instance of PatchOperation to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PatchOperation input)
        {
            if (input == null)
                return false;

            return 
                (
                    this.Op == input.Op ||
                    (this.Op != null &&
                    this.Op.Equals(input.Op))
                ) && 
                (
                    this.Path == input.Path ||
                    (this.Path != null &&
                    this.Path.Equals(input.Path))
                ) && 
                (
                    this.Value == input.Value ||
                    this.Value != null &&
                    this.Value.SequenceEqual(input.Value)
                );
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.Op != null)
                    hashCode = hashCode * 59 + this.Op.GetHashCode();
                if (this.Path != null)
                    hashCode = hashCode * 59 + this.Path.GetHashCode();
                if (this.Value != null)
                    hashCode = hashCode * 59 + this.Value.GetHashCode();
                return hashCode;
            }
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            yield break;
        }
    }

}
